import Request from '@/common/utils/request';
/**
 * 创建工单
 */
const create = ({
  actualRepairPlace,
  appointment,
  completeTime,
  createTime,
  degree,
  deptId,
  enclosure,
  equipment,
  equipmentAddress,
  equipmentAddressId,
  faultRemark,
  faultType,
  learningId,
  phone,
  place,
  rangeType,
  reqTime,
  responseType,
  sendObjId,
  sendObjType,
  sendTeam,
  sendType,
  source,
  user,
} = {}) => Request.post('/obstacles/server/addOrder', {
  actualRepairPlace,
  appointment,
  completeTime,
  createTime,
  degree,
  deptId,
  enclosure,
  equipment,
  equipmentAddress,
  equipmentAddressId,
  faultRemark,
  faultType,
  learningId,
  phone,
  place,
  rangeType,
  reqTime,
  responseType,
  sendObjId,
  sendObjType,
  sendTeam,
  sendType,
  source,
  user,
});
/**
 * 派单
 */
const dispatch = ({
  ticketId,
  sendObjId,
  sendObjType,
  sendTeam,
} = {}) => Request.put('/obstacles/server/allocate', {
  orderNum: ticketId,
  sendObjId,
  sendObjType,
  sendTeam,
});
/**
 * 退单
 */
const sendBack = ({
  ticketId,
  reason,
  remark,
} = {}) => Request.put('/obstacles/mine/order/reback', {
  orderNum: ticketId,
  reason,
  remark,
});
/**
 * 处理完成工单
 */
const complete = ({
  actualRepairPlace,
  equipment,
  equipmentAddress,
  equipmentAddressId,
  faultRemark,
  faultType,
  makeTime,
  makeWay,
  orderNum,
  processEnclosure,
  realTime,
} = {}) => Request.put('/obstacles/mine/order/complete', {
  actualRepairPlace,
  equipment,
  equipmentAddress,
  equipmentAddressId,
  faultRemark,
  faultType,
  makeTime,
  makeWay,
  orderNum,
  processEnclosure,
  realTime,
});
/**
 * 处理工单
 */
const deal = ({
  ticketId,
  processEnclosure,
  remark,
} = {}) => Request.put('/obstacles/mine/order/make', {
  orderNum: ticketId,
  processEnclosure,
  remark,
});
/**
 * 接单
 */
const accept = (orderNum) => Request.put('/obstacles/mine/order/receive', {
  orderNum,
});
/**
 * 暂停工单
 */
const suspend = ({
  enclosure,
  ticketId,
  reason,
  remark,
} = {}) => Request.put('/obstacles/mine/order/suspend', {
  enclosure,
  orderNum: ticketId,
  reason,
  remark,
});
/**
 * 暂停开启
 */
const openSuspended = (orderNum) => Request.put('/obstacles/mine/order/open', {
  orderNum,
});
/**
 * 终止工单
 */
const terminate = ({
  ticketId,
  reason,
  remark,
} = {}) => Request.put('/obstacles/mine/order/termination', {
  orderNum: ticketId,
  reason,
  remark,
});
/**
 * 终止重启
 */
const restartTerminated = (orderNum) => Request.put('/obstacles/mine/order/restart', {
  orderNum,
});
/**
 * 转交工单
 */
const transfer = ({
  ticketId,
  reason,
  remark,
  sendObjId,
  sendObjType,
  sendTeam,
} = {}) => Request.put('/obstacles/mine/order/redirect', {
  orderNum: ticketId,
  reason,
  remark,
  sendObjId,
  sendObjType,
  sendTeam,
});
/**
 * 多人协作
 * assistList: [{assistEnclosureId,content,sendObjId,sendObjType,sendTeam}]
 */
const assist = ({
  assistList,
  ticketId,
  assistEnclosure,
  assistRemark,
} = {}) => Request.put('/obstacles/mine/order/assist', {
  assistList,
  orderNum: ticketId,
  assistEnclosure,
  assistRemark,
});
/**
 * 工单升级
 * proposeLIst: [{organizer,phone,sponsor}]
 */
const upgrade = ({
  aboutSystem,
  enclosure,
  endTime,
  level,
  orderNum,
  proposeList,
  remark,
  startTime,
  title,
} = {}) => Request.put('/obstacles/mine/order/upgrade', {
  aboutSystem,
  enclosure,
  endTime,
  level,
  orderNum,
  proposeList,
  remark,
  startTime,
  title,
});
/**
 * 通过审核
 */
const passAudit = (orderNumList) => Request.get(`/obstacles/order/enact?orderNums=${orderNumList.join(',')}`);
/**
 * 驳回审核
 */
const notPassAudit = ({
  orderNum,
  rejectReason,
  rejectDescribe,
} = {}) => Request.post('/obstacles/order/reject', {
  orderNum,
  rejectReason,
  rejectDescribe,
});
/**
 * 获取工单详情
 */
const detail = (orderNum) => Request.get(`/obstacles/server/detail/${orderNum}`, {});
/**
 * 获取工单流程信息
 */
const processFlow = (ticketId) => Request.get(`/obstacles/server/detail/process/${ticketId}`);
/**
 * 无效电话
 * @param {Number} callRecordId 通话记录ID
 */
const invalidPhone = (callRecordId) => Request.put('/obstacles/server/deal/invalid', {
  data: callRecordId,
});
export default {
  create,
  accept,
  detail,
  sendBack,
  complete,
  deal,
  suspend,
  openSuspended,
  terminate,
  restartTerminated,
  transfer,
  assist,
  upgrade,
  passAudit,
  notPassAudit,
  processFlow,
  invalidPhone,
  dispatch,
};
